<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/jsp/taglibs.jsp"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<base href="<%=basePath%>" />
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<meta http-equiv="X-UA-Compatible" content="IE=7" />
	<title>report right</title>
	<link id="editCss" rel="stylesheet" type="text/css" href="<%=basePath%>css/right.css" />
	<script type="text/javascript" src="<%=basePath%>js/base.js"></script>
	<script type="text/javascript" src="<%=basePath%>js/popUpBase.js"></script>
</head>

<body>
<div class="crumbs">
	当前位置：首页 &gt; 角色管理
</div>
<div class="search">
	<div class="tab" >
		<span class="right"></span>
		<span class="font-blue14pxb">角色管理</span>
    </div>
</div>
<form method="post">
<div class="search">
	<ul class="con minHeight">
		<li style="width:auto;">
			<input type="button" class="button" value="添加角色" style="margin-left: 5px" onclick="javascript:showAddDialog()" />
		</li>
	</ul>
</div>
<div class="tableBox">
	<input type="hidden" name="hiddenId" id="hiddenId" />
	<table cellPadding="0" cellSpacing="0" border="0" width="100%"
		id="tableList"
		style="border-collapse: collapse; empty-cells: show;">
		<tr>
			<th>
				序号
			</th>
			<th>
				角色ID
			</th>
			<th>
				角色名称
			</th>
			<th>
				角色描述
			</th>
			<th>
				操作
			</th>
			<th>
				权限
			</th>
		</tr>
		<c:forEach items="${list}" var="role" varStatus="index">
			<tr>
				<td >
					${index.count }
				</td>
				<td >
					${role["ROLE_ID"]}
				</td>
				<td >
					${role["ROLE_NAME"]}
				</td>
				<td>
					${role["DESCRIPTION"]}
				</td>
				<td>
					<img src="<%=path %>/images/icon/list_edit.gif" style="margin-bottom: 1px"  />
					<a href="javascript:void(0);" 
						onclick="javascript:showAddDialog(this.parentNode.parentNode)" >
						<span style="margin-bottom: 1px">修改</span>
					</a>	
					|
					<img src="<%=path %>/images/icon/list_del.gif" style="margin-bottom: 1px"/>
					<a href="javascript:void(0);"
						onclick="deleteData('${role["ROLE_ID"]}','${role["ROLE_NAME"]}');" >
						<span style="margin-bottom: 1px">删除</span>
					</a>
				</td>
				<td>
					<input type="button" class="button" value="查看权限"
						onclick="showPermission('${role["ROLE_ID"]}')" />
				</td>
			</tr>
		</c:forEach>
	</table>
</div>
<%@include file="/jsp/pagination.jsp"%>
</form>
</body>

	<script type="text/javascript">
		function showAddDialog(parent){
			var url ='<%=basePath%>jsp/role/add.jsp' ;
			if(arguments.length > 0){
				 var tds =	parent.cells ;
				 url +='?id='+trim(tds[1].innerHTML)+"　"+'&name='+trim(tds[2].innerHTML)+'&des='+trim(tds[3].innerHTML)+'' ;
			}
			top.popUp('role_add', '添加角色',url, 400, 208,function() {});
		}
		  
		function deleteData(id,name){
			document.getElementById("hiddenId").value = id ;
			if(window.confirm("确定要删除名称为 "+name+" 这条数据么?")){
				document.forms[0].action="<%=basePath%>servlet/role?action=deleteData";
				document.forms[0].submit();
			}
		}
		
		function showPermission(id){
			top.popUp('role_view', '查看角色权限',"<%=basePath%>rpv?roleId="+id, 400, 330,function() {});
		}
		
		function trim(v){
			return (v==null || v==undefined)?"":v.replace(/^\s*/, "").replace(/\s*$/,""); 
		}
	</script>
</html>